function myInterval(fn, time) {
    /** 获取最新的定时器ID */
    let res = {
        target: ''
    }
    function test() {
        fn();
        res.target = setTimeout(test, time);
    }
    test();
    return res;
}

function myClearInterval(timer) {
    clearTimeout(timer.target);
}

let t = myInterval(()=> {
    console.log(111)
}, 1000)

setTimeout(() => {
    myClearInterval(t);
}, 2000);
